package cn.itrip.auth.controller;

import cn.itrip.beans.Dto.Dto;
import cn.itrip.beans.pojo.ItripUser;
import cn.itrip.common.DtoUtil;
import cn.itrip.common.RedisUtil;
import org.springframework.mobile.device.Device;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class LoginController {


    @Resource
    private ItripUser user;

    @RequestMapping(value = "/dologin",method = RequestMethod.POST)
    public Dto login(String userName, String password, Device device){
       if (user!=null) {
           if (user.getActivated() == 0) {
               return DtoUtil.getFail();
           }
          // RedisUtil.setValueExpire()
           //生成一个token，：来源-用户id编码加密-用户id-生成时间-6为随机码
           return DtoUtil.getSuccesDto();


          // return userService


       }
       return DtoUtil.getFail();
    }
}
